import { axiosInstance } from "..";

function GetUinfo(docid:string,username:string,type:string){
    return new Promise((resolve,reject)=>{
        axiosInstance().post("/improveAchievement/interview/getuinfo",{docid,username,type}).then(
            (res:any)=>{
                resolve(res)
            },
            (err:any)=>{
                reject(err)
            }
        )
    })
}

function GetInterviewInfo(docid:string){
    return new Promise((resolve,reject)=>{
        axiosInstance().post("/improveAchievement/interview/interviewinfo",{docid}).then(
            (res:any)=>{
                resolve(res)
            },
            (err:any)=>{
                reject(err)
            }
        )
    })
}

function SendInterview(param:string){
    return new Promise((resolve,reject)=>{
        axiosInstance().post("/improveAchievement/interview/sendinterview",{param}).then(
            (res:any)=>{
                resolve(res)
            },
            (err:any)=>{
                reject(err)
            }
        )
    })
}

function GetInterviewLines(docid:string,seq:number){
    return new Promise((resolve,reject)=>{
        axiosInstance().post("/improveAchievement/interview/getlines",{docid,seq}).then(
            (res:any)=>{
                resolve(res)
            },
            (err:any)=>{
                reject(err)
            }
        )
    })
}

function UploadSign(file:Blob,docid:string,flow_code:string,username:string,seq:string){
    const formData = new FormData()
    formData.append('file',file)
    formData.append('docid',docid)
    formData.append('flow_code',flow_code)
    formData.append('username',username)
    formData.append('seq',seq)
    formData.append('filename',"temp_file")
    return new Promise((resolve,reject)=>{
        axiosInstance().post("/improveAchievement/interview/uploadsign",formData).then(
            (res:any)=>{
                resolve(res)
            },
            (err:any)=>{
                reject(err)
            }
        )
    })
}


export {GetUinfo,GetInterviewInfo,SendInterview,UploadSign,GetInterviewLines}